/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import View.InvitationsTable;
import View.MessageTable;
import agh.rozproszony.model.Message;
import agh.rozproszony.model.User;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Strawa
 */
public class Threading extends Thread {

    ReservationController controller;
    MessagesController msgController;
    MessageTable messageTable;

    public Threading(ReservationController tempController,
            MessagesController tempMsgController,
            MessageTable tempMessageTable) {

        this.controller = tempController;
        this.msgController = tempMsgController;
        this.messageTable = tempMessageTable;


    }

    public void run() {

        while (true) {
                messageTable.Clear();
                List<Message> msg = msgController.getLastMessages(30);
                List<User> users = controller.getAllUsers();


                messageTable.addMessage(msg, users);
                messageTable.fireTableStructureChanged();
        }
    }
}
